import {Component, OnInit} from 'angular2/core';
import {RouteParams} from 'angular2/router';
import {HeroService} from '../../fasade/hero.service';
import {Hero} from '../../model/hero';

@Component({
    selector: 'my-hero-detail',
    templateUrl: 'app/bundles/hero/tpls/detail.component.html',
    inputs: ['hero'],
    styleUrls: ['app/bundles/hero/css/detail.component.css']
})
export class HeroDetailComponent implements OnInit {
    hero: Hero
    
    constructor(
        private _heroService: HeroService,
        private _routeParams: RouteParams
    ) {
        
    }
    
    goBack() {
        window.history.back();
    }
    
    ngOnInit() {
        let id = +this._routeParams.get('id');
        this._heroService.getHero(id)
            .then(hero => this.hero = hero);
    }
}